package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {
    //插入菜品数据
    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);
    //条件分页查询
    List<DishVO> selectPage(DishPageQueryDTO dishPageQueryDTO);

    //设置菜品起售停售
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    //根据id批量删除菜品
    void deleteByIds(List<Long> ids);

    //根据id查询菜品基本信息
    @Select("select * from dish where id = #{id}")
    Dish selectById(Long id);

    //根据分类id查询菜品
    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> selectByCategoryId(Long categoryId);

    //根据ids查询起售中的菜品数量
    Integer countByIds(List<Long> ids);

    //根据分类id查询菜品(包含口味信息)
    List<DishVO> selectByCategoryIdWithFlavor(Long categoryId);

    /*
    *根据分类id查询菜品数量
    * */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
